<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=rzi1SdGriyCMknUEWdTSO9GMqKsFgXQZ"></script>
    <title>企业坐标查询</title>
    <style type="text/css">
        *{
            margin:0px;
            padding:0px;
        }
        input#mapbutton{
            width: 50px;
            height: 34px;
            margin: 5px 10px;
            text-align: center;
            font: 14px/34px "微软雅黑";
        }
        input#mapaddress,input#maplatlng{
            width:300px;
            height: 30px;
            font: 14px/30px "微软雅黑";
            margin: 5px 0  ;
        }
        span{
            color: #666;
        }
        #container {
            min-width:603px;
            min-height:767px;
        }
    </style>
</head>
<body>

<input type="text" id="mapaddress" placeholder="为保证精确搜索，请加上省市" />
<input type="button" id="mapbutton" value="搜索" onclick="search()" />
<input id="maplatlng" type="text" value="坐标" style="display: none"><span style="display: none">提示：复制坐标并返回设置页面进行粘贴</span>
<div style="width:100%;height:100%;" id="container"></div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");
    map.centerAndZoom(new BMap.Point(121.461165,31.234095), 11);
    function search(){
        var myAddress = document.getElementById('mapaddress').value;

        var myGeo = new BMap.Geocoder();
        myGeo.getPoint(myAddress, function(point){ //第一步getPoint是地址解析,获取输入框的地址
            if (point) {
                map.centerAndZoom(point, 16);
                map.addOverlay(new BMap.Marker(point));

                myGeo.getLocation(point, function(rs){ //第二步getLocation是反地址解析，获取输入地址的坐标并显示在input里面
                        $("#maplatlng").show().val(point.lng + ", " + point.lat);
                        $("span").show();
                });
            }
        }, "北京市"); //必须设置城市

    }
</script>